package cn.plushine.service;

import cn.plushine.mapper.BaseGoodsMapper;
import cn.plushine.pojo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * 商品信息
 */
@Service
public class BaseGoodsServiceImpl implements BaseGoodsService {

    @Autowired
    BaseGoodsMapper baseGoodsMapper;

    // 获取货物信息
    @Override
    public List<Goods> get() {
        return baseGoodsMapper.get();
    }

    // 获取品牌列表
    @Override
    public List<Brand> getBrand() {
        return baseGoodsMapper.getBrand();
    }

    // 获取单位列表
    @Override
    public List<Unit> getUnit() {
        return baseGoodsMapper.getUnit();
    }

    // 获取仓库列表
    @Override
    public List<Warehouse> getWarehouse() {
        return baseGoodsMapper.getWarehouse();
    }

    // 获取分区列表
    @Override
    public List<WarehouseArea> getArea(int id) {
        return baseGoodsMapper.getArea(id);
    }

    // 获取库位列表
    @Override
    public List<WarehousePosition> getPosition(int id) {
        return baseGoodsMapper.getPosition(id);
    }

    // 修改货物信息
    @Override
    public int modify(HashMap goods) throws Exception {
        int modifyDB = baseGoodsMapper.modify(goods);
        if (modifyDB != 0) {
            return modifyDB;
        }
        throw new Exception("修改货物信息失败！");
    }

    // 删除货物图片
    @Override
    public int deleteImage(int gid) {
        return baseGoodsMapper.deleteImage(gid);
    }

    // 添加货物图片
    @Override
    public int addImage(int gid, int id, String url) {
        return baseGoodsMapper.addImage(gid, id, url);
    }

    // 删除货物规格
    @Override
    public int deleteLabel(int gid) {
        return baseGoodsMapper.deleteLabel(gid);
    }

    // 添加货物规格
    @Override
    public int addLabel(int gid, int id, String name) {
        return baseGoodsMapper.addLabel(gid, id, name);
    }

    // 添加货物信息
    @Override
    public int add(HashMap goods) throws Exception {
        int modifyDB = baseGoodsMapper.add(goods);
        if (modifyDB != 0) {
            return modifyDB;
        }
        throw new Exception("添加货物信息失败！");
    }

    // 查询最新货物id
    @Override
    public int getFinallyGoods() {
        return baseGoodsMapper.getFinallyGoods();
    }
}
